package com.leetcode.algorithm.y22.m07.w3;

/**
 * 459. 重复的子字符串
 * 
 * https://leetcode.cn/problems/repeated-substring-pattern/
 * 
 * @author jie.deng
 *
 */
class Question0459Solution01 {

	public boolean repeatedSubstringPattern(String s) {
		int len = s.length();
		for (int i = 1; i <= len / 2; i++) {
			if (len % i != 0) {
				continue;
			}
			int from = i;
			String str = s.substring(0, from);
			while (from + i <= len && str.equals(s.substring(from, from + i))) {
				from += i;
			}
			if (from == len) {
				return true;
			}
		}
		return false;
	}

}